#ifndef __PID_H
#define __PID_H

#include "main.h"

typedef struct
{
	float kp,ki,kd;			//pid系数
	float target_val;		//目标值
	float error;			//当前误差值
	float error_last;		//上一次误差值
	float integral;			//积分值
	float output_val;		//输出实际值
	float p_limit;			//误差限幅
	float i_limit;			//积分限幅
	float output_limit;		//输出限幅
} pos_pid_t;


typedef struct
{
	float kp,ki,kd;			//pid系数
	float target_val;		//目标值
	float error_now;		//当前误差
	float error_last1;		//上一次误差
	float error_last2;		//上上次误差
	float increase_val;		//输出增量
	float output_limit;		//输出限幅
} inc_pid_t;



void position_Pid_Init(pos_pid_t *pid, float kp, float ki, float kd, float p_limit, float i_limit, float target, float limit);
float position_Pid_Realize(pos_pid_t *pid,float actual_val);

void increasing_Pid_Init(inc_pid_t *pid, float kp, float ki, float kd, float target_val);
float increasing_Pid_Realize(inc_pid_t *pid, float actual_value);

#endif


